package ophiux.common.parse.xml;

import java.util.ArrayList;
import java.util.List;

import ophiux.api.sdk.OphiuxApiException;
import ophiux.api.sdk.test.ClzFXTestModel;
import ophiux.api.sdk.test.ClzTypeTestModel;
import ophiux.common.parse.IConvert;
import ophiux.common.parse.IOphiuxApiParser;
import ophiux.common.parse.IOphiuxApiWriter;

/**
 * xml写入
 * @author chenh
 *
 */
public class OphiuxApiXMLWriter<T> implements IOphiuxApiWriter<T> {

	
	@Override
	public String writer(T obj) throws OphiuxApiException {
		// TODO Auto-generated method stub
		IConvert xmlConverter = new XmlConverter();
		return xmlConverter.entityToString(obj);
	}
	
	public static void main(String[] args) {
		ClzFXTestModel fxModel = new ClzFXTestModel();
		fxModel.setName("浪仔");
		fxModel.setAge(32);
		ClzTypeTestModel testModel = new ClzTypeTestModel();
		List<ClzFXTestModel> list = new ArrayList<ClzFXTestModel>();
		list.add(fxModel);
		list.add(fxModel);
		list.add(fxModel);
		testModel.setTestList(list);
		
		OphiuxApiXMLWriter dd=new OphiuxApiXMLWriter<ClzTypeTestModel>();
		try {
			System.out.println(dd.writer(testModel));
		} catch (OphiuxApiException e) {
			e.printStackTrace();
		}
		
		
	}

}
